package com.littlepay.kr4.paulin.dfeba77;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.littlepay.kr4.paulin.dfeba77.R;
import com.littlepay.kr4.paulin.dfeba77.fragment.UserSettingFragment;
import com.littlepay.kr4.paulin.dfeba77.utils.PrefUtils;

import butterknife.BindView;


/**
 * Created by john on 2017/5/22.
 */

public class UserSettingActivity extends AppCompatActivity {
    Toolbar toolbar;
    Button logoutButton;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        String stringvalue = PreferenceManager.getDefaultSharedPreferences(this)
//                .getString("rename","");
        setContentView(R.layout.activity_user_setting);
        toolbar = (Toolbar) findViewById(R.id.toolbar_user_preference);
        setSupportActionBar(toolbar);
        if(toolbar != null){
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowTitleEnabled(false);
        }
//        TextView textView3 = (TextView)findViewById(R.id.textView3);
//        String stringvalue =  PrefUtils.getname();
//        if(!Objects.equals(stringvalue, "")){
//            textView3.setText(stringvalue);
//        }else {
//            textView3.setText("暂未设置昵称");
//        }

        getFragmentManager().beginTransaction().replace(R.id.content_frame1, new UserSettingFragment()).commit();
        logoutButton = (Button) findViewById(R.id.logout_button);
        logoutButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PrefUtils.setLogin(false);
                finish();
            }
        });

    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case android.R.id.home:
                finish();
                break;
        }
        return false;
    }
}
